<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <input v-model="message" placeholder="edit me" />
      <p>Message is: {{ message }}</p>

      <hr />

      <span>Multiline message is:</span>
      <p style="white-space: pre-line">{{ message2 }}</p>
      <br />
      <textarea v-model="message2" placeholder="add multiple lines"></textarea>

      <hr />

      <!-- 如果变量只被一个多选框绑定，类型是布尔值 -->
      <input
        type="checkbox"
        id="checkbox"
        v-model="checked"
        true-value="yes"
        false-value="no"
      />
      <label for="checkbox">{{ checked }}</label>

      <hr />

      <!-- 如果变量同时被多个多选框绑定，类型是数组  -->
      <input type="checkbox" id="jack" value="Jack" v-model="checkedNames" />
      <label for="jack">Jack</label>
      <input type="checkbox" id="john" value="John" v-model="checkedNames" />
      <label for="john">John</label>
      <input type="checkbox" id="mike" value="Mike" v-model="checkedNames" />
      <label for="mike">Mike</label>
      <br />
      <span>Checked names: {{ checkedNames }}</span>

      <hr />

      <!-- 单选框绑定的是value值 -->
      <input type="radio" id="one" value="One" v-model="picked" />
      <label for="one">One</label>
      <br />
      <input type="radio" id="two" value="Two" v-model="picked" />
      <label for="two">Two</label>
      <br />
      <span>Picked: {{ picked }}</span>

      <hr />

      <select v-model="selected">
        <option disabled value="">请选择</option>
        <option value="1">男</option>
        <option value="0">女</option>
        <option value="-1">未知</option>
      </select>
      <span>Selected: {{ selected }}</span>
    </div>

    <script src="../Vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          message: "1",
          message2: "",
          checked: true,
          checkedNames: [],
          picked: "Two",
          selected: "",
        },
      });
    </script>
  </body>
</html>
